package main

import client_updater.ForeverFrameServlet
import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.Context
import org.mortbay.jetty.servlet.ServletHolder
import client_commands._
import client_updater.UpdatesActor
import client_updater.NewClientServlet
import executors._

/**
 * The main class of the application.<br>
 * initialize all the servlets and actors
 */
object ClientManager extends App{

  /**
   * The main method of the application.<br>
   * initialize all the servlets and actors
   */
  override def main(args: Array[String]) = {
	val port : Int = 1234
    val actorsPort : Int = 4444
    val server = new Server(port);
    val root = new Context(server, "/", Context.SESSIONS);
    val ffs = new ForeverFrameServlet();
    val ncs = new NewClientServlet();
    root.addServlet(new ServletHolder(ncs), "/NewClient")
    root.addServlet(new ServletHolder(ffs), "/login");
    //root.addServlet(new ServletHolder(hs), "/HelloServlet");
    val cfa = new ChangedFileActor(actorsPort, new ChangedFileExecutor)
    cfa.start
    val dfia = new DeletedFileActor(actorsPort, new DeletedFileExecutor)
    dfia.start
    val dfoa = new DeletedFolderActor(actorsPort, new DeletedFolderExecutor)
    dfoa.start
    val nfia = new NewFileActor(actorsPort, new NewFileExecutor)
    nfia.start
    val nfoa = new NewFolderActor(actorsPort, new NewFolderExecutor)
    nfoa.start
    val ufa = new UploadFileActor(actorsPort, new UploadFileExecutor)
    ufa.start
    val upa = new UpdatesActor(actorsPort)
    upa.start
    
    server.start
        
    
    server.join
    cfa ! "Quit"
    dfia ! "Quit"
    dfoa ! "Quit"
    nfia ! "Quit"
    nfoa ! "Quit"
    ufa ! "Quit"
    upa ! "Quit"
    
  }

}




